package com.gitee.wsl.common.ui.graphics.color

import androidx.annotation.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import com.gitee.wsl.ext.base.ColorExt
import com.gitee.wsl.ext.base.HSVSpec
import kotlinx.serialization.Serializable

@Serializable
data class HSVColor(
    val h: Float,
    val s: Float,
    val v: Float,
)

fun Color.toHSVSpec(): HSVSpec {
    val hsv = FloatArray(3)
    val color: Int = this.toArgb()
    Color.colorToHSV(color, hsv)
    return HSVSpec(hsv[0], hsv[1], hsv[2])
}

/**
 * Convert the ARGB color to its HSV components.
 *
 *  * `hsv[0]` is Hue \([0..360[\)
 *  * `hsv[1]` is Saturation \([0...1]\)
 *  * `hsv[2]` is Value \([0...1]\)
 *
 * @param color the argb color to convert. The alpha component is ignored.
 * @param hsv  3 element array which holds the resulting HSV components.
 */
fun Color.Companion.colorToHSV(color: Int, @Size(3) hsv: FloatArray) {
    TODO("待实现")
    //RGBToHSV((color shr 16) and 0xFF, (color shr 8) and 0xFF, color and 0xFF, hsv)
}

fun HSVColor.toColor():Color{
    TODO("待实现")
}